package top.ljlgithub.api.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.ljlgithub.api.bean.Attr;
import top.ljlgithub.api.mapper.AttrMapper;
import top.ljlgithub.api.service.AttrService;

import java.util.List;

/**
 * @ClassName
 * @Description TODO
 * @Author L1470
 * @Date 2021/5/7 9:39
 * @Version 1.0
 **/
@Service
public class AttrServiceImpl implements AttrService {
    @Autowired
    AttrMapper attrMapper;

    @Override
    public List<Attr> getAttrList(Integer id, String sel) {
        return attrMapper.getAttrList(id,sel);
    }

    @Override
    public Attr addAttr(Attr attr) {
        attr.setAttr_write("list");
        attrMapper.addAttr(attr);
        return attr;
    }

    @Override
    public void deleteAttr(Integer id, Integer attrid) {
        attrMapper.deleteAttr(id, attrid);
    }

    @Override
    public Attr findAttrById(Integer id, Integer attrid) {
        Attr attr = attrMapper.findAttrById(id, attrid);
        return attr;
    }

    @Override
    public Attr updateAttr(Attr attr) {
        attr.setAttr_write("manual");
        attrMapper.updateAttr(attr);
        return attr;
    }
}
